package view;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

public class DiplayMessagePanel extends JPanel implements ActionListener {

	private ClientFrame frame;
	// private JLabel messageLabel;
	private JButton backButton;
	private JTextArea resultArea;
	private JScrollPane scrollingArea;

	public DiplayMessagePanel(ClientFrame f, String message) {
		frame = f;
		this.setBounds(0, 0, frame.getWidth(), frame.getHeight());
		this.setBackground(Color.WHITE);
		this.setLayout(null);

		// messageLabel = new JLabel(message);
		// messageLabel.setBounds(300, 150, 300, 20);
		// this.add(messageLabel);

		resultArea = new JTextArea();
		resultArea.setText(message);
		resultArea.setEditable(false);
		resultArea.setWrapStyleWord(true);
		scrollingArea = new JScrollPane(resultArea);
		scrollingArea.setBounds(300, 120, 300, 100);
		this.add(scrollingArea);

		backButton = new JButton("Back");
		backButton.setBounds(300, 250, 80, 20);
		backButton.addActionListener(this);
		this.add(backButton);
		this.repaint();

		frame.setContentPane(this);

	}

	public void actionPerformed(ActionEvent e) {

		if (e.getSource() == backButton) {
			frame.goToLoginPanel();
		}

	}
}
